
<div class="sanpham_detail">
     <?php
		$id = $_GET['msp'];
		$sanpham = new sanphambs();
		$sanpham->MaSanPham = $id;
		$sanpham->AscNumView();
		$danhsach = $sanpham->GetList();
    	
            $hinhanh = new hinhanhbs();
            $hinhanh->MaSanPham = $danhsach['0']['MaSanPham'];
            $dshinh = $hinhanh->GetList();
            echo " 
             <div class='slider_hinhsp'><a href='index.php?do=chitietsanpham&msp={$danhsach[0]['MaSanPham']}'>
                <img src='{$dshinh[0]['patch']}' width='200px' height='250px'/>
             </a>
             </div>
                
             <div class='slider_thongtinsp'>
             <h2 class='TenSP'>". $danhsach[0]['TenSanPham']."</h2>
             <p class='luotxem'>" . $danhsach[0]['LuotXem'] . " Lượt Xem</p>
            <span class='GiaBan'> Giá bán:" . number_format($danhsach[0]['DonGia']) . " VNĐ</span>
            
             <table>
                
                <tr> <td><span class='thongtin_sp'> Xuất xứ:</span></td><td>". $danhsach[0]['TenNhaSX']."</td></tr>
                <tr> <td><span class='thongtin_sp'> Loại sản phẩm </span></td><td>". $danhsach[0]['TenLoai']."</td></tr>
				<tr> <td><span class='thongtin_sp'> Nhóm hàng</span></td><td>". $danhsach[0]['TenNhomHang']."</td></tr>
             </table>
             
             <span class='themgiohang'>
					<span class='giohang'>
							<a href='index.php?do=giohang'><img src='images/giohang.jpg' width='50px' /></a>
						</span>
						<span class='thanhtoan'>
							<a href='index.php?do=thanhtoan'><img src='images/thanhtoan.jpg' width='50px' /></a>
						</span>
			 </span>
						
             </div>
             
            ";
        
    ?>
</div>   
    
    
    <?php
        echo "<div class='MoTa'>{$danhsach[0]['MoTa']}</div>";
    ?>
<?php
	$binhluan = new binhluanbs();
	$binhluan->MaSanPham = $_GET['msp'];
	$dsbinhluan = $binhluan->GetList_SP();
	if($dsbinhluan == true)
	{
		echo "<p style = 'color: #0000ff'><b>Bình luận gần đây:</b></p>";
		echo "<ul style = 'list-style-image: url(images/bullet.gif)'>";
		for($i = count($dsbinhluan) - 1; $i >= 0; $i--)
		{	
			$tgbinhluan = InNgay($dsbinhluan[$i]['ThoiGianBinhLuan']);
			if(isset($_SESSION['MaNguoiDung']))
			{
				if($dsbinhluan[$i]['MaNguoiDung'] == $_SESSION['MaNguoiDung'])
					echo "<li><b style = 'color: #1e90ff'>" . $dsbinhluan[$i]['TenNguoiDung'] . ":</b> " . $dsbinhluan[$i]['NoiDungBinhLuan'] . " <span style = 'color: #778899;font-size: 12px;margin: 0;'>(" . $tgbinhluan . ")</span> <a href = 'binhluan_xoa_" . $dsbinhluan[$i]['MaBinhLuan'] . "_" . $_GET['msp'] . "' onclick='return confirm(\"Bạn có muốn xóa bình luận không?\")'><img src = 'images/delete.png' title = 'Xóa bình luận'/></a></li>";
				else
					echo "<li><b style = 'color: #1e90ff'>" . $dsbinhluan[$i]['TenNguoiDung'] . ":</b> " . $dsbinhluan[$i]['NoiDungBinhLuan'] . " <span style = 'color: #778899;font-size: 12px;margin: 0;'>(" . $tgbinhluan . ")</span> </li>";
			}
			else
			{
				echo "<li><b style = 'color: #1e90ff'>" . $dsbinhluan[$i]['TenNguoiDung'] . ":</b> " . $dsbinhluan[$i]['NoiDungBinhLuan'] . " <span style = 'color: #778899;font-size: 12px;margin: 0;'>(" . $tgbinhluan . ")</span> </li>";
			}
		}
		echo "</ul>";
	}
	
	if(isset($_SESSION['MaNguoiDung']))
	{
		echo "<p style = 'color: #0000ff'><b>Bình luận mới:</b></p>";
		echo "<form action = 'binhluan_them' method = 'POST'>";
			echo "<table class = 'FormSuaBaiViet'>";
				echo "<input type='hidden' name='MaSanPham' value='" . $sanpham->MaSanPham . "' />";
				echo "<input type='hidden' name='MaNguoiDung' value='" . $_SESSION['MaNguoiDung'] . "' />";
				echo "<tr>";
					echo "<td><textarea name = 'NoiDungBinhLuan'></textarea>
							<script type='text/javascript'>
								var editor = CKEDITOR.replace('NoiDungBinhLuan');
							</script>
					</td>";
				echo "</tr>";
				echo "<tr>";
					echo "<td><input type = 'submit' value = 'Bình luận'/></td>";
				echo "</tr>";
			echo "</table>";
		echo "</form>";
	}
	else
	{
		echo "<p style = 'color: #0000ff'><b>Bình luận mới:</b> <a href = 'trangchu'>Đăng nhập để bình luận</a></p>";
	}
?>

